ld/dwarf: increase includestack from 16 to 64#143
Conversation
APE headers have deep transitive include chains that exceed the original Go-era limit of 16. 64 is enough for real-world nesting. https://claude.ai/code/session_01WGAwvvTwDg2yknFkmZ3qzs
There was a problem hiding this comment.
Code Review
This pull request increases the size of the includestack array from 16 to 64 in sys/src/cmd/ld/dwarf.c to handle deeper include hierarchies. The review feedback suggests avoiding the use of a magic number by using a named constant or the nelem() macro and recommends increasing the limit further to 128 to ensure safety for extremely deep include chains.
| int file; | ||
| vlong line; | ||
| } includestack[16]; | ||
| } includestack[64]; |
There was a problem hiding this comment.
Increasing the stack size to 64 addresses the immediate issue, but using a hardcoded magic number is risky if bounds checks elsewhere in the code (e.g., in addhistfile) are not updated to match. It is recommended to use a named constant or the nelem() macro to ensure the array size and its bounds checks remain in sync. Additionally, given the minimal memory impact, a larger limit like 128 might be safer for extremely deep include chains.
} includestack[128];
APE headers have deep transitive include chains that exceed the original Go-era limit of 16. 64 is enough for real-world nesting.
https://claude.ai/code/session_01WGAwvvTwDg2yknFkmZ3qzs